Add advice for god-mode support to hide popup
authorjustbur <justin@burkett.cc>
Tue, 26 Apr 2016 18:26:25 +0000 (14:26 -0400)
committerjustbur <justin@burkett.cc>
Tue, 26 Apr 2016 18:26:25 +0000 (14:26 -0400)
The standard way to hide the popup before the command is not working.

which-key.el

index 23f71917451325b50f3d60a72146849ff7a7f4cd..a78d49562a6199c23d09a3cba7693fb2224c1a7f 100644 (file)
@@ -514,22 +514,36 @@ problems at github.")
 (defvar which-key--god-mode-key-string nil
   "Holds key string to use for god-mode support.")
 
-(defadvice god-mode-lookup-command (before which-key--god-mode-advice disable)
+(defadvice god-mode-lookup-command
+    (before which-key--god-mode-lookup-command-advice disable)
   (setq which-key--god-mode-key-string (ad-get-arg 0)))
 
+(defadvice god-mode-self-insert
+    (after which-key--god-mode-self-insert-advice disable)
+  (which-key--hide-popup))
+
 (defun which-key-enable-god-mode-support (&optional disable)
   "Enable support for god-mode if non-nil. This is experimental,
 so you need to explicitly opt-in for now. Please report any
 problems at github. If DISABLE is non-nil disable support."
   (interactive "P")
   (setq which-key--god-mode-support-enabled (null disable))
-  (ad-deactivate 'god-mode-lookup-command)
   (if disable
-      (ad-disable-advice 'god-mode-lookup-command
-                         'before 'which-key--god-mode-advice)
-    (ad-enable-advice 'god-mode-lookup-command
-                      'before 'which-key--god-mode-advice))
-  (ad-activate 'god-mode-lookup-command))
+      (progn
+        (ad-disable-advice
+         'god-mode-lookup-command
+         'before 'which-key--god-mode-lookup-command-advice)
+        (ad-disable-advice
+         'god-mode-self-insert
+         'after 'which-key--god-mode-self-insert-advice))
+    (ad-enable-advice
+     'god-mode-lookup-command
+     'before 'which-key--god-mode-lookup-command-advice)
+    (ad-enable-advice
+     'god-mode-self-insert
+     'after 'which-key--god-mode-self-insert-advice))
+  (ad-activate 'god-mode-lookup-command)
+  (ad-activate 'god-mode-self-insert))
 
 ;;;###autoload
 (define-minor-mode which-key-mode